<template>
  <el-card class="execution-engine">
    <template #header>
      <div class="list-header">
        <div class="left-bar">
          <el-dropdown>
            <el-button type="primary">
              批量操作
              <el-icon class="el-icon--right">
                <arrow-down />
              </el-icon>
            </el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item :icon="Delete as any">删除</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
        <div class="right-bar">
          <el-input size="default" placeholder="请输入关键字">
            <template #append>
              <el-button size="default" :icon="Search as any" />
            </template>
          </el-input>
          <el-button size="default" type="primary">
            新建
            <el-icon class="el-icon--right">
              <plus />
            </el-icon>
          </el-button>
        </div>
      </div>
    </template>
    <el-table :data="data" style="width: 100%">
      <el-table-column type="selection" width="40" />
      <el-table-column prop="name" label="名称" width="180" />
      <el-table-column prop="type" label="资源管理" />
      <el-table-column prop="createTime" sortable label="接入时间">
        <template #default="scope: { row: ExecutionEngine }">
          {{ moment(scope.row.createTime).format('yyyy-MM-DD HH:mm:ss') }}
        </template>
      </el-table-column>
      <el-table-column prop="updateTime" sortable label="修改时间">
        <template #default="scope: { row: ExecutionEngine }">
          {{ moment(scope.row.updateTime).format('yyyy-MM-DD HH:mm:ss') }}
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template #default>
          <el-tooltip effect="dark" content="检测" placement="top">
            <el-button type="primary" size="small" circle :icon="Detection as any"></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="删除" placement="top">
            <el-button type="danger" size="small" :icon="Delete as any" circle />
          </el-tooltip>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 15px; justify-content: flex-end"
      :small="true"
      background
      layout="prev, pager, next"
      :total="1000"
    />
  </el-card>
</template>
<script lang="ts" setup>
import { ArrowDown, Delete, Plus, Search } from '@element-plus/icons-vue'
import { Detection } from '@icon-park/vue-next'
import { doQueryExecutionEngineList, ExecutionEngine } from '@/api/execution-engine-api'
import { onMounted, ref } from 'vue'
import moment from 'moment'

const data = ref([])

function queryExecutionEngineList() {
  doQueryExecutionEngineList().then((res) => {
    data.value = res.data
  })
}

onMounted(() => {
  queryExecutionEngineList()
})
</script>
<style lang="scss" scoped>
.execution-engine {
  .list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .right-bar {
      display: flex;
      align-items: center;

      > div {
        margin: 0 5px;
      }
    }
  }
}
</style>
